let App = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    page:1,
    size:10,
    refresh:false,
    down:false,
    value: '',
    allData:true,
  },
  //去处理
  handle(e){
    console.log(e)
    let id = e.currentTarget.dataset.id
    wx.navigateTo({
      url: '../orderReturn/index?id='+id
    })
  },
    //查看订单
    lookOrder(e){
      let id = e.currentTarget.dataset.id
      wx.navigateTo({
        url: '../order/index?id='+id
      })
    },
    onChange(e) {
      this.setData({
        value: e.detail,
      });
    },
    onSearch() {
      console.log('搜索' + this.data.value);
    },
    // cancelSearch(){
    //   debugger
    //     this.getList()
    // },
    onClick() {
      console.log('搜索' + this.data.value);
      let that = this
      let data = {
        page:that.data.page,
        pagesize:that.data.size,
        // realname:this.data.value,
        mobile:this.data.value
      }
      App._get(App.Domain+'Handler/Applet/getWaitingOrder', data, function (result) {
        if(result.code == 1){
          that.setData({
            orderList:result.data.list
          })
        }
      })
    },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      page:1
     })
      this.getList()
  },
  getList(){
    let that = this
    let data = {
      page:that.data.page,
      pagesize:that.data.size
    }
    App._get(App.Domain+'Handler/Applet/getWaitingOrder', data, function (result) {
      if(result.code == 1){
        if(result.data.list.length<10){
         that.setData({
            allData:false,
            notData:true
         })
        }
        if(that.data.page == 1){
          that.setData({
            orderList: result.data.list
          })
        }else{
          that.setData({
            orderList:that.data.orderList.concat(result.data.list)
          })
        }
      }
    });
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
   
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },
  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },
//下拉刷新
onPullDownRefresh() {
  this.setData({refresh:true,allData:true,page:1,notData:false})
  this.getList()
  wx.showNavigationBarLoading() 
  setTimeout(()=>{
    this.getData = '数据拿到了'
    this.setData({refresh:false})
    wx.stopPullDownRefresh()
    wx.hideNavigationBarLoading()
  },1000)
},
//触底加载
onReachBottom:function(options){
  if(!this.data.allData){
    return
  }else{
    this.setData({
      down:true
    })
    setTimeout(()=>{
      this.getData = '数据拿到了'
      this.setData({down:false})
      wx.stopPullDownRefresh()
      wx.hideNavigationBarLoading()
    },1000)
    let page = this.data.page
    page++
    this.setData({page:page})
    this.getList()
  }
},

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})